package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddBook  implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("新增图书");
        if (bookList.isFull()==true){
            System.out.println("满了不能放");
            return;
        }
        System.out.println("请输入新增图书的书名：");
        Scanner scanner=new Scanner(System.in);
        String bookName=scanner.nextLine();
        System.out.println("请输入新增书的作者");
        String author=scanner.nextLine();
        System.out.println("请输入新增书的价格");
        int price=scanner.nextInt();
        scanner.nextLine();
        System.out.println("请输入新增书的类型");
        String type=scanner.nextLine();
        Book book=new Book(bookName,author,price,type);
        int current=bookList.getUsedSize();
        bookList.setBook(book,current);
        bookList.setUsedSize(current+1);
        System.out.println("新增图书成功");
    }
}
